package sy10_4;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 8088);
        OutputStream outputStream = socket.getOutputStream();
        outputStream.write("请求上传图片".getBytes());
        InputStream inputStream = socket.getInputStream();
        byte[] b = new byte[1024];
        int len;
        len = inputStream.read(b);
        System.out.println(new String(b, 0, len));
        FileInputStream fis = new FileInputStream("C:\\Users\\ASUS\\Pictures\\Screenshots\\屏幕截图 2023-10-30 101528.png");
        while ((len = fis.read(b)) != -1) {
            outputStream.write(b, 0, len);
        }
        socket.shutdownOutput();
        len = inputStream.read(b);
        System.out.println(new String(b, 0, len));
        socket.close();
    }
}